const storageProducts = store => {
    //状态从本地获取
    let res = localStorage.getItem('products') || '[]'
    //给store中的模块Product中的products赋值
    store.state.Product.products = JSON.parse(res)

    console.log(JSON.parse(res))
    console.log(store.state.Product.products)
    //订阅mutation的变化
    store.subscribe((mutations, state) => {
        console.log(state.Product.products)
        let products = state.Product.products
        //将属性存到本地
        // 判断是否设置了products
        // console.log('111')
        //存到本地
        localStorage.setItem('products', JSON.stringify(products))
    })
}

export default storageProducts